package cn.edu.gdpt.mobile213.mobile2121606097wjc0416;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class nameadapter extends RecyclerView.Adapter<nameadapter.ViewHolder>{
    String[] name;
    public nameadapter(String[] name){
        this.name=name;
    }
    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tvitemname;
        public ViewHolder(@NonNull View itemView){
            super(itemView);
            tvitemname=itemView.findViewById(R.id.tvitemname);
        }
    }
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView= LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_main_name,parent,false);
        ViewHolder viewHolder=new ViewHolder(itemView);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.tvitemname.setText(name[position]);
    }

    @Override
    public int getItemCount() {
        return name.length;
    }
}
